<template>
  <div>
    <el-input
      v-model="s_value"
      :disabled="disabled"
      @change="onChange"
      style="width: 300px"
    /><el-button @click="reg" type="primary" icon="el-icon-refresh-right" circle />
  </div>
</template>

<script>
import { generateID } from "@/utils/utils";
export default {
  name: "idInput",
  data() {
    return {
      s_value: "",
    };
  },
  methods: {
    onChange(v) {
      this.$emit("change", v);
    },
    reg() {
        this.s_value = generateID();
        this.onChange(this.s_value)
    }
  },
  props: {
    value: String,
    disabled: {
      type: Boolean,
      default: true,
    },
  },
  model: {
    prop: "value",
    event: "change",
  },
  
  mounted() {
    if (this.value) {
      this.s_value = this.value;
      // this.disabled = true
    } else {
      this.s_value = generateID();
      this.onChange(this.s_value);
    }
  },
};
</script>

<style>
</style>